package com.sjb.training.lc;

/**
 * Created with IntelliJ IDEA.
 * lc.26 删除有序数组中的重复项
 * @Author: 有点儿意思
 * @Description:
 */
public class RemoveRepeatNums {

    public static void main(String[] args) {
        int[] nums = {1,1,2};
        int duplicates = removeDuplicates(nums);
        System.out.println(duplicates);
    }



    public static int removeDuplicates(int[] nums) {
        int slow = 0;
        for (int fast = 0; fast < nums.length ; ) {
            if (nums[slow] == nums[fast]){
                fast ++;
            }else {
                slow ++;
                nums[slow] = nums[fast++];
            }
        }
        return slow + 1;
    }
}
